const app = getApp()
const api = require('../../../api/index.js')
const util = require("../../../utils/util.js")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    sport:[],
    imgSrc:'http://www.dicard.cn/Public/',
    id:'',
    removeData:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.sport()
    // this.setData({
    //   imgSrc: api.imgPathUrl
    // })
  },
  sport:function(){
    api.myUsers((res) =>{
      console.log(res)
      this.setData({
        sport: res.data.result
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },
  myPublish:function(){
    let community_id =  wx.getStorageSync('community').community_id
    console.log(community_id)
    if (community_id == undefined ){
      community_id = 9
    }
    wx.navigateTo({
      url: `/pages/community/issue/issue?id=${community_id}`,
    })
  },
  remove:function(e){
    let myCYID = e.currentTarget.dataset.remove
    this.setData({
      id: myCYID,
      removeData:true
    })
  },
  Delete:function(){
    let data = {
      note_id: this.data.id
    }
    let that  =  this;
    api.myRemove(data,(res)=>{
      console.log(res)
      if (res.data.descriptions == '删除失败'){
        that.setData({
          removeData: false
        })
        wx.showToast({
          title: '删除失败稍后再试',
          duration: 1000
        });
      }else{

        that.sport()
        that.setData({
          removeData: false
        })
       
        wx.showToast({
          title: '删除成功',
          duration: 1000
        });

      }
      

      
    })
  },
  removes:function(){
    this.setData({
      removeData: false
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

})